# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
pkgname=audaspace
pkgver=1.4.0
pkgrel=2
pkgdesc="A high level and feature rich audio library written in C++ with language bindings"
arch=(loong64 x86_64)
url="https://audaspace.github.io/"
license=(Apache)
depends=(
  'ffmpeg'
  'fftw'
  'gcc-libs'
  'glibc'
  'jack'
  'libpulse'
  'libsndfile'
  'openal'
  'sdl2'
)
makedepends=(
  'cmake'
  'python'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
  'python-numpy'
)
optdepends=(
  'python: python language bindings'
  'python-numpy: python language bindings'
)
source=("https://github.com/neXyon/audaspace/archive/v$pkgver/$pkgname-v$pkgver.tar.gz")
sha512sums=('a977356cc72f5b024d3819542326f85280c24bf16a9bee830e9818113345e5c3e3793e9b113b983b460161f3b827a3b110f40ae781082eacc72b7a5882c80d99')
b2sums=('1ccca9f19cd8491650cc20b1dc4f57ced2fbca13d97855303edaafa4ec6aa70aef4fedfd8bb738045d38270c2e62fd2714cccc50bce241b1d367bd7ce800e330')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_PREFIX=/usr
    -D DEFAULT_PLUGIN_PATH=/usr/lib/$pkgname/plugins
    -D WITH_JACK=ON
    -D WITH_PYTHON=ON
    -S $pkgname-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose

  cd build
  python -m build --wheel --no-isolation
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  python -m installer --destdir="$pkgdir" build/dist/*.whl
}
